package com.ziyia.viewmodel;

import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.Lifecycle;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
    private Integer i = 0;
    private TextView textView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        textView = findViewById(R.id.infoText);

        getSupportActionBar().setTitle("旋转屏幕Activity会刷新 - Test");



        Lifecycle lifecycle = getLifecycle();
        MyObserver myObserver = new MyObserver(lifecycle);
        lifecycle.addObserver(myObserver);
        myObserver.getActivityStatus();
    }

    public void ijj(View view) {
        i++;
        refreshI();
    }


    private void refreshI() {
        textView.setText(i.toString());
    }

    public void toViewModelTest(View view) {
        Intent intent = new Intent(MainActivity.this, ViewModelTest.class);
        startActivity(intent);
    }
}